package mdt.action;

import org.tigris.gef.base.Globals;

import javax.swing.*;
import javax.swing.text.StyledEditorKit;
import java.awt.*;
import java.awt.event.ActionEvent;

/**
 * Created by xiaobyu on 7/14/2016.
 */
public class SetTextColorAction extends AbstractAction{
    public SetTextColorAction() {
        super("Set Text Color");
        putValue(Action.SMALL_ICON, new ImageIcon(FontBoldAction.class.getResource("/resources/text_color-16.png")));
    }

    @Override
    public void actionPerformed(ActionEvent e) {

        JTextPane jtp = (JTextPane)Globals.curEditor().getActiveTextEditor();
        Color color = JColorChooser.showDialog(jtp,"Select a color", Color.black);
        new StyledEditorKit.ForegroundAction("set-foreground-color", color).actionPerformed(e);
    }
}
